#pragma once
#include"HashTable.h"

namespace sbt
{							//把缺省值从哈希表中传，改成从set传
	template<class K, class Hash = HashFunc<K>>
	class unordered_set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{ 
				return key;
			}
		};
	public:
		typedef typename hash_bucket::HashTable<K, K, SetKeyOfT,Hash>::const_iterator iterator;
		typedef typename hash_bucket::HashTable<K, K, SetKeyOfT, Hash>::const_iterator const_iterator;

		//去掉普通迭代器
		//iterator begin()
		//{
		//	return _ht.begin();
		//}

		//iterator end()
		//{
		//	return _ht.end();
		//}
		//普通对象也能调用const迭代器
		const_iterator begin()const
		{
			return _ht.begin();
		}

		const_iterator end()const
		{
			return _ht.end();
		}


		pair<const_iterator,bool> insert(const K& key)
		{
			auto ret = _ht.Insert(key);//返回的是普通迭代器	//用普通迭代器的值依次构造
			return pair<const_iterator, bool>(const_iterator(ret.first._node, ret.first._pht, ret.first._hashi),ret.second);
		}//返回构造出来的const迭代器

		iterator find(const K& key)
		{
			return _ht.Find(key);
		}

		bool erase(const K& key)
		{
			return _ht.Erase(key);
		}
	private:
		hash_bucket::HashTable<K, K, SetKeyOfT, Hash> _ht;
	};
}